<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script type="text/javascript" src="js/jquery-1.12.4.min.js"></script>
	<script type="text/javascript" src="js/jquery-ui.min.js"></script>
	<script type="text/javascript">
		
		$(function(){

			$('.box').draggable({

				axis:'x',   //限制在X轴

				containment:'parent',  //限制在父级

				opacity:0.6,   //设置拖动时的透明度

				drag:function(ev,ui){

					// console.log(ui);
										
					// document.title = ui.position.left;
					
					$('#show_num').val(parseInt(100*(ui.position.left)/700));


				}


			});

		})



	</script>
	<style type="text/css">
		.box{
			width:100px;
			height:100px;
			background-color:pink;
		}
		.con{
			width:800px;
			height:100px;
			margin:50px auto 0;
			border:1px solid black;
		}
	</style>
</head>
<body>
	<div class="con">
		<div class="box"></div>
	</div>
	<input type="text" name="" id="show_num">
</body>
</html>